package com.x.example.toolbar.items;

import android.content.Context;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.x.example.toolbar.TabItemView;
import com.example.uiframework.utils.Utils;

public class HomeToolbarItem extends TabItemView {

    TextView mTvTab;

    public HomeToolbarItem(@NonNull Context context, @NonNull String token) {
        super(context, token);
        mTvTab = new TextView(getContext());
        mTvTab.setTextColor(0xff333333);
        mTvTab.setGravity(Gravity.CENTER);
        mTvTab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
        this.addView(mTvTab, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        mTvTab.setText("首页");
    }

    @Override
    public void setItemSelectedProgress(float progress) {
        mTvTab.setTextColor(Utils.res.getColor(progress, COLOR_NORMAL, COLOR_SELECTED));
    }

    @Override
    public void setItemSelected(boolean selected) {
        mTvTab.setTextColor(selected ? COLOR_SELECTED : COLOR_NORMAL);
    }

}
